---
title: "Gov 2001 Replication Paper"
author: "Miro Bergam, Yanxi Fang, Dominic Skinnion"
date: "December 12, 2021"
output: pdf_document
---

```{r, warning = F, message = F, include = F}
# load packages
library(lfe)
library(lmtest)
library(plm)
library(stargazer)
library(tidyverse)

lag <- Hmisc::Lag
select <- dplyr::select
# read in data
df <- read.delim("./data/PoliticsProsperityJune2021.tab")
```

# Table 1

```{r}
# subset data
df_tab1 <- df %>%
  filter(year > 1870 & year < 1990)
# regress model 1
tab1_mod1 <- plm(Education_pc ~ leg_party_competition + year_1890 + year_1900 + 
                                year_1910 + year_1930 + year_1940 + year_1960 + 
                                year_1970 + year_1980, 
                 index = "state", data = df_tab1)
tab1_mod1_se <- coeftest(tab1_mod1, function(x) vcovHC(x, type = 'sss'))
# regress model 2
tab1_mod2 <- plm(Education_pc ~ leg_party_competition + Statewide_Competition + 
                                house_dem + senate_dem + gov_dem + 
                                CPI_per_capita_income + foreignborn_pct + 
                                black_pct + othernonwhite_pct + urban_pct + 
                                year_1890 + year_1900 + year_1910 + year_1930 + 
                                year_1940 + year_1960 + year_1970 + year_1980, 
                 index = "state", data = df_tab1)
tab1_mod2_se <- coeftest(tab1_mod2, function(x) vcovHC(x, type = 'sss'))
# regress model 3
tab1_mod3 <- plm(HealthSewerSanitation_pc ~ leg_party_competition + 
                                year_1890 + year_1900 + year_1910 + year_1930 +
                                year_1940 + year_1960 + year_1970 + year_1980,
                 index = "state", data = df_tab1)
tab1_mod3_se <-coeftest(tab1_mod3, function(x) vcovHC(x, type = 'sss'))
# regress model 4
tab1_mod4 <- plm(HealthSewerSanitation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct +
                                year_1890 + year_1900 + year_1910 + year_1930 +
                                year_1940 + year_1960 + year_1970 + year_1980,
                 index = "state", data = df_tab1)
tab1_mod4_se <-coeftest(tab1_mod4, function(x) vcovHC(x, type = 'sss'))
# regress model 5
tab1_mod5 <- plm(Transportation_pc ~ leg_party_competition +
                                year_1890 + year_1900 + year_1910 + year_1930 +
                                year_1940 + year_1960 + year_1970 + year_1980,
                 index = "state", data = df_tab1)
tab1_mod5_se <-coeftest(tab1_mod5, function(x) vcovHC(x, type = 'sss'))
    
# regress model 6             
tab1_mod6 <- plm(Transportation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct +
                                year_1890 + year_1900 + year_1910 + year_1930 +
                                year_1940 + year_1960 + year_1970 + year_1980,
                 index = "state", data = df_tab1)
tab1_mod6_se <-coeftest(tab1_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 1
stargazer(tab1_mod1_se, tab1_mod2_se, tab1_mod3_se, 
          tab1_mod4_se, tab1_mod5_se, tab1_mod6_se,
          header = F, type = "latex", digits = 2, style = "apsr",
          title = "Party Competition Predicts Higher Human Capital and Infrastructure Spending, 1880-1980",
          column.labels = c("Education spending", "Health spending",
                            "Transportation spending"),
          column.separate = c(2, 2, 2),
          covariate.labels = c("Legislative party competition",
                               "Electoral competition", "Democratic house",
                               "Democratic senate", "Democratic governor",
                               "Income per capita", "Foreign-born percentage",
                               "Black percentage", "Other nonwhite percentage", 
                               "Urban population percentage"),
          omit = c("Constant", "year_1890", "year_1900", "year_1910", "year_1920",
                   "year_1930", "year_1940", "year_1960", "year_1970", "year_1980"),
          add.lines = list(c("State fixed effects", "included", "included",
                             "included", "included", "included", "included"),
                           c("Year fixed effects", "included", "included",
                             "included", "included", "included", "included"),
                           c("Observations", "398", "380", "326", "310", "374", "357"),
                           c("R-Squared", "0.96", "0.97", "0.89", "0.92", "0.87", "0.89"),
                           c("Adj. R-Squared", "0.95", "0.96", "0.87", "0.90", "0.85", "0.87")))
```

\newpage

# Table 2

```{r}
# subset for model 1
df_tab2_mod1 <- df %>%
  filter(year >= 1930 & year < 2020)
# regress model 1
tab2_mod1 <- plm(infantmortality ~ HealthSewerSanitation_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct + othernonwhite_pct +
                                   urban_pct + as.factor(year),
                 index = "state", data = df_tab2_mod1)
tab2_mod1_se <- coeftest(tab2_mod1, function(x) vcovHC(x, type = 'sss'))
# subset for model 2
df_tab2_mod2 <- df %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(f3_at_birth_life_expectancy = dplyr::lead(at_birth_life_expectancy, 3)) %>%
  filter(year <= 1980)
# regress model 2
tab2_mod2 <- plm(f3_at_birth_life_expectancy ~ HealthSewerSanitation_pc +
                                   CPI_per_capita_income + foreignborn_pct + 
                                   black_pct + othernonwhite_pct + urban_pct +
                                   as.factor(year),
                 index = "state", data = df_tab2_mod2)
tab2_mod2_se <- coeftest(tab2_mod2, function(x) vcovHC(x, type = 'sss'))
# subset for model 3
df_tab2_mod3 <- df %>%
  filter(year >= 1880 & year <= 2010)
# regress model 3
tab2_mod3 <- plm(graduation_combined ~ Education_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct+ othernonwhite_pct +
                                   urban_pct + south + as.factor(year),
                 index = "state", data = df_tab2_mod3)
tab2_mod3_se <- coeftest(tab2_mod3, function(x) vcovHC(x, type = 'sss'))
# use same data as model 3, regress model 4
tab2_mod4 <- plm(illiteracy_proportional_30 ~ Education_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct + othernonwhite_pct +
                                   urban_pct + south + as.factor(year),
                 index = "state", data = df_tab2_mod3)
tab2_mod4_se <- coeftest(tab2_mod4, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 2
stargazer(tab2_mod1_se, tab2_mod2_se, tab2_mod3_se, tab2_mod4_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr",
          title = "Spending Levels Predict Development, 1880-2010",
          column.labels = c("Infant mortality", 
                            "Life expectancy (30 years later)",
                            "High school completion", 
                            "Illiteracy rate (30 years later)"),
          covariate.labels = c("Health, sewer, sanitation spending per capita",
                               "Education spending per capita", 
                               "Income per capita",
                               "Foreign-born percentage", "Black percentage", 
                               "Other nonwhite percentage", "Urban population percentage"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects",
                             "included", "included", "included", "included"),
                           c("Year fixed effects",
                             "included", "included", "included", "included"),
                           c("Observations", "240", "272", "374", "168"),
                           c("R-Squared", "0.92", "0.98", "0.96", "0.43"),
                           c("Adjusted R-Squared", "0.89", "0.97", "0.96", "0.14")))
```

\newpage

# Table 3

```{r}
# create new dataframe for "full sample"
df_tab3_full <- df
# subset for 1880-1940 sample
df_tab3_part <- df %>%
  filter(year >= 1880 & year <= 1940)
# regress model 1
tab3_mod1 <- plm(CPI_per_capita_income_next30 ~ HealthSewerSanitation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_full)
tab3_mod1_se <- coeftest(tab3_mod1, function(x) vcovHC(x, type = 'sss'))
# regress model 2
tab3_mod2 <- plm(CPI_per_capita_income_next30 ~ HealthSewerSanitation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_part)
tab3_mod2_se <- coeftest(tab3_mod2, function(x) vcovHC(x, type = 'sss'))
# regress model 3
tab3_mod3 <- plm(CPI_per_capita_income_next30 ~ Education_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_full)
tab3_mod3_se <- coeftest(tab3_mod3, function(x) vcovHC(x, type = 'sss'))
# regress model 4
tab3_mod4 <- plm(CPI_per_capita_income_next30 ~ Education_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_part)
tab3_mod4_se <- coeftest(tab3_mod4, function(x) vcovHC(x, type = 'sss'))
# regress model 5
tab3_mod5 <- plm(CPI_per_capita_income_next30 ~ Transportation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_full)
tab3_mod5_se <- coeftest(tab3_mod5, function(x) vcovHC(x, type = 'sss'))
# regress model 6
tab3_mod6 <- plm(CPI_per_capita_income_next30 ~ Transportation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_tab3_part)
tab3_mod6_se <- coeftest(tab3_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 3
stargazer(tab3_mod1_se, tab3_mod2_se, tab3_mod3_se, 
          tab3_mod4_se, tab3_mod5_se, tab3_mod6_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr", digits = 2,
          title = "Health and Education Spending Levels Predict Income (Only in Pre-New Deal Period)",
          column.labels = c("Full sample", "1880-1940", 
                            "Full sample", "1880-1940",
                            "Full sample", "1880-1940"),
          covariate.labels = c("Health, sewer, sanitation spending per capita",
                               "Education spending per capita", 
                               "Transportation spending per capita", 
                               "Income per capita",
                               "Foreign-born pct", "Black pct", 
                               "Other nonwhite pct", "Urban population pct"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects",
                             "included", "included", "included", 
                             "included", "included", "included"),
                           c("Year fixed effects",
                             "included", "included", "included", 
                             "included", "included", "included"),
                           c("Observations", "336", "192", "408", 
                             "264", "384", "240"),
                           c("Orig. R-Squared", "0.98", "0.99", "0.98", 
                             "0.98", "0.98", "0.98"),
                           c("R-Squared", "0.92", "0.99", "0.93", 
                             "0.97", "0.93", "0.97"),
                           c("Adjusted R-Squared", "0.91", "0.98", "0.91", 
                             "0.96", "0.91", "0.96")))
```

\newpage

# Extension 1.1: Use Lagged Values with Year and State FEs for Table 1

```{r}
# subset for Lag Table 1
df_lag1 <- df_tab1 %>%
  select(Education_pc, HealthSewerSanitation_pc, Transportation_pc,
         leg_party_competition, Statewide_Competition, house_dem, 
         senate_dem, gov_dem, CPI_per_capita_income, foreignborn_pct, black_pct, 
         othernonwhite_pct, urban_pct, state, year, year_1890, year_1900, year_1910,
         year_1920, year_1930, year_1940, year_1950, year_1960, year_1970, year_1980)
# create lagged variables
df_lag1 <- df_lag1 %>%
  mutate(lag_Education_pc = ifelse(year != 1880, lag(Education_pc), NA)) %>%
  mutate(lag_Health_pc = ifelse(year != 1880, lag(HealthSewerSanitation_pc), NA)) %>%
  mutate(lag_Transportation_pc = ifelse(year != 1880, lag(Transportation_pc), NA))
# regress Lag Table 1, Model 1
lag1_mod1 <- plm(Education_pc ~ lag_Education_pc + leg_party_competition +
            year_1890 + year_1900 + year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, index = "state", data = df_lag1)
lag1_mod1_se <- coeftest(lag1_mod1, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 1, Model 2
lag1_mod2 <- plm(Education_pc ~ lag_Education_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct + year_1890 + year_1900 + 
            year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, 
            index = "state", data = df_lag1)
lag1_mod2_se <- coeftest(lag1_mod2, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 1, Model 3
lag1_mod3 <- plm(HealthSewerSanitation_pc ~ lag_Health_pc + leg_party_competition +
            year_1890 + year_1900 + year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, index = "state", data = df_lag1)
lag1_mod3_se <- coeftest(lag1_mod3, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 1, Model 4
lag1_mod4 <- plm(HealthSewerSanitation_pc ~ lag_Health_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct + year_1890 + year_1900 + 
            year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, 
            index = "state", data = df_lag1)
lag1_mod4_se <- coeftest(lag1_mod4, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 1, Model 5
lag1_mod5 <- plm(Transportation_pc ~ lag_Transportation_pc + leg_party_competition +
            year_1890 + year_1900 + year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, index = "state", data = df_lag1)
lag1_mod5_se <- coeftest(lag1_mod5, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 1, Model 6
lag1_mod6 <- plm(Transportation_pc ~ lag_Transportation_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct + year_1890 + year_1900 + 
            year_1910 + year_1920 + year_1930 + year_1940 + 
            year_1950 + year_1960 + year_1970 + year_1980, 
            index = "state", data = df_lag1)
lag1_mod6_se <- coeftest(lag1_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 8: Lagged Table 1
stargazer(lag1_mod1_se, lag1_mod2_se, lag1_mod3_se, 
          lag1_mod4_se, lag1_mod5_se, lag1_mod6_se,
          header = F, type = "latex", digits = 2, style = "apsr",
          title = "Party Competition Does NOT Predict Human Capital and Infrastructure Spending, 1880-1980",
          column.labels = c("Education spending", "Health spending",
                            "Transportation spending"),
          column.separate = c(2, 2, 2),
          covariate.labels = c("Lagged education spending", "Lagged health spending",
                               "Lagged transportation spending", 
                               "Legislative party competition",
                               "Electoral competition", "Democratic house",
                               "Democratic senate", "Democratic governor",
                               "Income per capita", "Foreign-born percentage",
                               "Black percentage", "Other nonwhite percentage", 
                               "Urban population percentage"),
          omit = c("Constant", "year_1890", "year_1900", "year_1910", 
                   "year_1920", "year_1930", "year_1940", "year_1950", 
                   "year_1960", "year_1970", "year_1980"),
          add.lines = list(c("State fixed effects", 
                             "included", "included", "included", 
                             "included", "included", "included"),
                           c("Year fixed effects",
                             "included", "included", "included", 
                             "included", "included", "included"),
                           c("Observations", "258", "249", "187", "182", "234", "228"),
                           c("R-Squared", "0.97", "0.98", "0.89", "0.92", "0.93", "0.94"),
                           c("Adj. R-Squared", "0.97", "0.97", "0.85", "0.87", "0.91", "0.91")))
```

\newpage

# Extension 1.2: Use Lagged Values with Year and State FEs for Table 2

```{r}
# subset for overall Lag Table 2
df_lag2 <- df %>%
  select(infantmortality, at_birth_life_expectancy, graduation_combined, 
         illiteracy_proportional_30, Education_pc, HealthSewerSanitation_pc,
         leg_party_competition, Statewide_Competition, house_dem, 
         senate_dem, gov_dem, CPI_per_capita_income, foreignborn_pct, black_pct, 
         othernonwhite_pct, urban_pct, state, year, south)
# subset for Lag Table 2, Model 1
df_lag2_mod1 <- df_lag2 %>%
  mutate(lag_infantmortality = ifelse(year != 1880, lag(infantmortality), NA)) %>%
  filter(year >= 1930 & year < 2020)
# regress Lag Table 2, Model 1
lag2_mod1 <- plm(infantmortality ~ lag_infantmortality + HealthSewerSanitation_pc + 
                 CPI_per_capita_income + foreignborn_pct + black_pct + 
                 othernonwhite_pct + urban_pct + as.factor(year),
                 index = "state", data = df_lag2_mod1)
lag2_mod1_se <- coeftest(lag2_mod1, function(x) vcovHC(x, type = 'sss'))
# subset for Lag Table 2, Model 2
df_lag2_mod2 <- df_lag2 %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(f3_at_birth_life_expectancy = dplyr::lead(at_birth_life_expectancy, 3)) %>%
  filter(year <= 1980)
# regress Lag Table 2, Model 2
lag2_mod2 <- plm(f3_at_birth_life_expectancy ~ at_birth_life_expectancy +
                   HealthSewerSanitation_pc + CPI_per_capita_income +
                   foreignborn_pct + black_pct + othernonwhite_pct +
                   urban_pct + as.factor(year),
                 index = "state", data = df_lag2_mod2)
lag2_mod2_se <- coeftest(lag2_mod2, function(x) vcovHC(x, type = 'sss'))
# subset for Lag Table 2, Models 3 and 4
df_lag2_mod3 <- df_lag2 %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(lag_graduation_combined = ifelse(year != 1880, lag(graduation_combined), NA)) %>%
  mutate(illiteracy_20 = lag(illiteracy_proportional_30))
# regress Lag Table 2, Model 3
lag2_mod3 <- plm(graduation_combined ~ lag_graduation_combined + Education_pc +
                   CPI_per_capita_income + foreignborn_pct + black_pct +
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_lag2_mod3)
lag2_mod3_se <- coeftest(lag2_mod3, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 2, Model 4
# note: the lagged variable is the illiteracy rate 20 years later
lag2_mod4 <- plm(illiteracy_proportional_30 ~ illiteracy_20 + Education_pc +
                   CPI_per_capita_income + foreignborn_pct + black_pct +
                   othernonwhite_pct + urban_pct + south + as.factor(year),
                 index = "state", data = df_lag2_mod3)
lag2_mod4_se <- coeftest(lag2_mod4, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 9: Lagged Table 2
stargazer(lag2_mod1_se, lag2_mod2_se, lag2_mod3_se, lag2_mod4_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr",
          title = "Spending Levels Do NOT Predict Development, 1880-2010",
          column.labels = c("Infant mortality", 
                            "Life expectancy (30 years later)",
                            "High school completion", 
                            "Illiteracy rate (30 years later)"),
          covariate.labels = c("Lagged infant mortality", "Current life expectancy",
                               "Health spending per capita", 
                               "Lagged high school completion", "Illiteracy (20 years later)",
                               "Education spending per capita", "Income per capita",
                               "Foreign-born percentage", "Black percentage", 
                               "Other nonwhite percentage", "Urban population percentage"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects",
                             "included", "included", "included", "included"),
                           c("Year fixed effects",
                             "included", "included", "included", "included"),
                           c("Observations", "215", "181", "336", "134"),
                           c("R-Squared", "0.98", "0.99", "0.98", "0.72"),
                           c("Adjusted R-Squared", "0.98", "0.98", "0.97", "0.52")))
```

\newpage

# Extension 2.1: Use Lagged Values, Without State Fixed Effects, for Table 1

```{r}
# subset for Lag Table 3 (Table 1, Without State FEs)
df_lag3 <- df_tab1 %>%
  select(Education_pc, HealthSewerSanitation_pc, Transportation_pc,
         leg_party_competition, Statewide_Competition, house_dem, 
         senate_dem, gov_dem, CPI_per_capita_income, foreignborn_pct, black_pct, 
         othernonwhite_pct, urban_pct, state, year, year_1890, year_1900, year_1910,
         year_1920, year_1930, year_1940, year_1950, year_1960, year_1970, year_1980)
# create lagged variables
df_lag3 <- df_lag3 %>%
  mutate(lag_Education_pc = ifelse(year != 1880, lag(Education_pc), NA)) %>%
  mutate(lag_Health_pc = ifelse(year != 1880, lag(HealthSewerSanitation_pc), NA)) %>%
  mutate(lag_Transportation_pc = ifelse(year != 1880, lag(Transportation_pc), NA))
# regress Lag Table 3, Model 1
lag3_mod1 <- plm(Education_pc ~ lag_Education_pc + leg_party_competition, 
                 index = "year", data = df_lag3)
lag3_mod1_se <- coeftest(lag3_mod1, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 3, Model 2
lag3_mod2 <- plm(Education_pc ~ lag_Education_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct, 
            index = "year", data = df_lag3)
lag3_mod2_se <- coeftest(lag3_mod2, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 3, Model 3
lag3_mod3 <- plm(HealthSewerSanitation_pc ~ lag_Health_pc + leg_party_competition,
                 index = "year", data = df_lag3)
lag3_mod3_se <- coeftest(lag3_mod3, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 3, Model 4
lag3_mod4 <- plm(HealthSewerSanitation_pc ~ lag_Health_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct, 
            index = "year", data = df_lag3)
lag3_mod4_se <- coeftest(lag3_mod4, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 3, Model 5
lag3_mod5 <- plm(Transportation_pc ~ lag_Transportation_pc + leg_party_competition,
                 index = "year", data = df_lag3)
lag3_mod5_se <- coeftest(lag3_mod5, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 3, Model 6
lag3_mod6 <- plm(Transportation_pc ~ lag_Transportation_pc + leg_party_competition +
            Statewide_Competition + house_dem + senate_dem + gov_dem + 
            CPI_per_capita_income + foreignborn_pct + black_pct + 
            othernonwhite_pct + urban_pct, 
            index = "year", data = df_lag3)
lag3_mod6_se <- coeftest(lag3_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 10: Lagged Table 3 (Table 1, Without State FEs)
stargazer(lag3_mod1_se, lag3_mod2_se, lag3_mod3_se, 
          lag3_mod4_se, lag3_mod5_se, lag3_mod6_se,
          header = F, type = "latex", digits = 2, style = "apsr",
          title = "Party Competition Does NOT Predict Human Capital and Infrastructure Spending, 1880-1980",
          column.labels = c("Education spending", "Health spending",
                            "Transportation spending"),
          column.separate = c(2, 2, 2),
          covariate.labels = c("Lagged education spending", "Lagged health spending",
                               "Lagged transportation spending", 
                               "Legislative party competition",
                               "Electoral competition", "Democratic house",
                               "Democratic senate", "Democratic governor",
                               "Income per capita", "Foreign-born percentage",
                               "Black percentage", "Other nonwhite percentage", 
                               "Urban population percentage"),
          omit = c("Constant", "year"),
          add.lines = list(c("State fixed effects", 
                             "No", "No", "No", 
                             "No", "No", "No"),
                           c("Year fixed effects",
                             "Yes", "Yes", "Yes", 
                             "Yes", "Yes", "Yes"),
                           c("Observations", "258", "249", "187", "182", "234", "228"),
                           c("R-Squared", "0.55", "0.58", "0.40", "0.52", "0.62", "0.64"),
                           c("Adj. R-Squared", "0.54", "0.56", "0.38", "0.48", "0.61", "0.62")))
```

\newpage

# Extension 2.2: Use Lagged Values, Without State Fixed Effects, For Table 2

```{r}
# subset for overall Lag Table 4 (Table 2, Without State FEs)
df_lag4 <- df %>%
  select(infantmortality, at_birth_life_expectancy, graduation_combined, 
         illiteracy_proportional_30, Education_pc, HealthSewerSanitation_pc,
         leg_party_competition, Statewide_Competition, house_dem, 
         senate_dem, gov_dem, CPI_per_capita_income, foreignborn_pct, black_pct, 
         othernonwhite_pct, urban_pct, state, year, south)
# subset for Lag Table 2, Model 1
df_lag4_mod1 <- df_lag4 %>%
  mutate(lag_infantmortality = ifelse(year != 1880, lag(infantmortality), NA)) %>%
  filter(year >= 1930 & year < 2020)
# regress Lag Table 2, Model 1
lag4_mod1 <- plm(infantmortality ~ lag_infantmortality + HealthSewerSanitation_pc + 
                 CPI_per_capita_income + foreignborn_pct + black_pct + 
                 othernonwhite_pct + urban_pct, index = "year", data = df_lag4_mod1)
lag4_mod1_se <- coeftest(lag4_mod1, function(x) vcovHC(x, type = 'sss'))
# subset for Lag Table 2, Model 2
df_lag4_mod2 <- df_lag4 %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(f3_at_birth_life_expectancy = dplyr::lead(at_birth_life_expectancy, 3)) %>%
  filter(year <= 1980)
# regress Lag Table 2, Model 2
lag4_mod2 <- plm(f3_at_birth_life_expectancy ~ at_birth_life_expectancy +
                   HealthSewerSanitation_pc + CPI_per_capita_income +
                   foreignborn_pct + black_pct + othernonwhite_pct +
                   urban_pct, index = "year", data = df_lag4_mod2)
lag4_mod2_se <- coeftest(lag4_mod2, function(x) vcovHC(x, type = 'sss'))
# subset for Lag Table 2, Models 3 and 4
df_lag4_mod3 <- df_lag4 %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(lag_graduation_combined = ifelse(year != 1880, lag(graduation_combined), NA)) %>%
  mutate(illiteracy_20 = lag(illiteracy_proportional_30))
# regress Lag Table 2, Model 3
lag4_mod3 <- plm(graduation_combined ~ lag_graduation_combined + Education_pc +
                   CPI_per_capita_income + foreignborn_pct + black_pct +
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_lag4_mod3)
lag4_mod3_se <- coeftest(lag4_mod3, function(x) vcovHC(x, type = 'sss'))
# regress Lag Table 2, Model 4
# note: the lagged variable is the illiteracy rate 20 years later
lag4_mod4 <- plm(illiteracy_proportional_30 ~ illiteracy_20 + Education_pc +
                   CPI_per_capita_income + foreignborn_pct + black_pct +
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_lag4_mod3)
lag4_mod4_se <- coeftest(lag4_mod4, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 11: Lagged Table 4
stargazer(lag4_mod1_se, lag4_mod2_se, lag4_mod3_se, lag4_mod4_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr",
          title = "Spending Levels Do NOT Predict Development, 1880-2010",
          column.labels = c("Infant mortality", 
                            "Life expectancy (30 years later)",
                            "High school completion", 
                            "Illiteracy rate (30 years later)"),
          covariate.labels = c("Lagged infant mortality", "Current life expectancy",
                               "Health spending per capita", 
                               "Lagged high school completion", "Illiteracy (20 years later)",
                               "Education spending per capita", "Income per capita",
                               "Foreign-born percentage", "Black percentage", 
                               "Other nonwhite percentage", "Urban population percentage"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects", "No", "No", "No", "No"),
                           c("Year fixed effects", "Yes", "Yes", "Yes", "Yes"),
                           c("Observations", "215", "181", "336", "134"),
                           c("R-Squared", "0.86", "0.70", "0.84", "0.68"),
                           c("Adjusted R-Squared", "0.85", "0.68", "0.84", "0.66")))
```

\newpage

# Extension 3.1: Removing the State Fixed Effects from Table 1

```{r}
# subset data
df_tab5 <- df %>%
  filter(year > 1870 & year < 1990)
# regress model 1
tab5_mod1 <- plm(Education_pc ~ leg_party_competition, 
                 index = "year", data = df_tab5)
tab5_mod1_se <- coeftest(tab5_mod1, function(x) vcovHC(x, type = 'sss'))
# regress model 2
tab5_mod2 <- plm(Education_pc ~ leg_party_competition + Statewide_Competition + 
                                house_dem + senate_dem + gov_dem + 
                                CPI_per_capita_income + foreignborn_pct + 
                                black_pct + othernonwhite_pct + urban_pct, 
                 index = "year", data = df_tab5)
tab5_mod2_se <- coeftest(tab5_mod2, function(x) vcovHC(x, type = 'sss'))
# regress model 3
tab5_mod3 <- plm(HealthSewerSanitation_pc ~ leg_party_competition,
                 index = "year", data = df_tab5)
tab5_mod3_se <- coeftest(tab5_mod3, function(x) vcovHC(x, type = 'sss'))
# regress model 4
tab5_mod4 <- plm(HealthSewerSanitation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct,
                 index = "year", data = df_tab5)
tab5_mod4_se <- coeftest(tab5_mod4, function(x) vcovHC(x, type = 'sss'))
# regress model 5
tab5_mod5 <- plm(Transportation_pc ~ leg_party_competition,
                 index = "year", data = df_tab5)
tab5_mod5_se <- coeftest(tab5_mod5, function(x) vcovHC(x, type = 'sss'))
    
# regress model 6             
tab5_mod6 <- plm(Transportation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct,
                 index = "year", data = df_tab5)
tab5_mod6_se <- coeftest(tab5_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 5
stargazer(tab5_mod1_se, tab5_mod2_se, tab5_mod3_se, 
          tab5_mod4_se, tab5_mod5_se, tab5_mod6_se,
          header = F, type = "latex", digits = 2, style = "apsr",
          title = "Party Competition Predicts Higher Human Capital and Infrastructure Spending, 1880-1980",
          column.labels = c("Education spending", "Health spending",
                            "Transportation spending"),
          column.separate = c(2, 2, 2),
          covariate.labels = c("Legislative party competition",
                               "Electoral competition", "Democratic house",
                               "Democratic senate", "Democratic governor",
                               "Income per capita", "Foreign-born percentage",
                               "Black percentage", "Other nonwhite percentage", 
                               "Urban population percentage"),
          omit = c("Constant"),
          add.lines = list(c("State fixed effects", "No", "No",
                             "No", "No", "No", "No"),
                           c("Year fixed effects", "Yes", "Yes",
                             "Yes", "Yes", "Yes", "Yes"),
                           c("Observations", "398", "380", "326", "310", "374", "357"),
                           c("R-Squared", "0.09", "0.33", "0.09", "0.42", "0.02", "0.20"),
                           c("Adj. R-Squared", "0.07", "0.30", "0.07", "0.39", "0.00", "0.16")))
```

\newpage

# Extension 3.2: Removing the State Fixed Effects from Table 2

```{r}
# subset for model 1
df_tab6_mod1 <- df %>%
  filter(year >= 1930 & year < 2020)
# regress model 1
tab6_mod1 <- plm(infantmortality ~ HealthSewerSanitation_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct + othernonwhite_pct +
                                   urban_pct,
                 index = "year", data = df_tab6_mod1)
tab6_mod1_se <- coeftest(tab6_mod1, function(x) vcovHC(x, type = 'sss'))
# subset for model 2
df_tab6_mod2 <- df %>%
  filter(year >= 1880 & year <= 2010) %>%
  mutate(f3_at_birth_life_expectancy = dplyr::lead(at_birth_life_expectancy, 3)) %>%
  filter(year <= 1980)
# regress model 2
tab6_mod2 <- plm(f3_at_birth_life_expectancy ~ HealthSewerSanitation_pc +
                                   CPI_per_capita_income + foreignborn_pct + 
                                   black_pct + othernonwhite_pct + urban_pct,
                 index = "year", data = df_tab6_mod2)
tab6_mod2_se <- coeftest(tab6_mod2, function(x) vcovHC(x, type = 'sss'))
# subset for model 3
df_tab6_mod3 <- df %>%
  filter(year >= 1880 & year <= 2010)
# regress model 3
tab6_mod3 <- plm(graduation_combined ~ Education_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct+ othernonwhite_pct +
                                   urban_pct + south,
                 index = "year", data = df_tab6_mod3)
tab6_mod3_se <- coeftest(tab6_mod3, function(x) vcovHC(x, type = 'sss'))
# use same data as model 3, regress model 4
tab6_mod4 <- plm(illiteracy_proportional_30 ~ Education_pc + CPI_per_capita_income +
                                   foreignborn_pct + black_pct + othernonwhite_pct +
                                   urban_pct + south,
                 index = "year", data = df_tab6_mod3)
tab6_mod4_se <- coeftest(tab6_mod4, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 6
stargazer(tab6_mod1_se, tab6_mod2_se, tab6_mod3_se, tab6_mod4_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr",
          title = "Spending Levels Predict Development, 1880-2010",
          column.labels = c("Infant mortality", 
                            "Life expectancy (30 years later)",
                            "High school completion", 
                            "Illiteracy rate (30 years later)"),
          covariate.labels = c("Health, sewer, sanitation spending per capita",
                               "Education spending per capita", 
                               "Income per capita",
                               "Foreign-born percentage", "Black percentage", 
                               "Other nonwhite percentage", "Urban population percentage"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects", "No", "No", "No", "No"),
                           c("Year fixed effects", "Yes", "Yes", "Yes", "Yes"),
                           c("Observations", "240", "272", "374", "168"),
                           c("R-Squared", "0.28", "0.44", "0.55", "0.32"),
                           c("Adjusted R-Squared", "0.25", "0.42", "0.54", "0.28")))
```

\newpage

# Extension 3.3: Removing State Fixed Effects from Table 3

```{r}
# create new dataframe for "full sample"
df_tab7_full <- df %>%
  filter(year >= 1880 & year <= 2010)
# subset for 1880-1940 sample
df_tab7_part <- df %>%
  filter(year >= 1880 & year <= 1940)
# regress model 1
tab7_mod1 <- plm(CPI_per_capita_income_next30 ~ HealthSewerSanitation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_full)
tab7_mod1_se <- coeftest(tab7_mod1, function(x) vcovHC(x, type = 'sss'))
# regress model 2
tab7_mod2 <- plm(CPI_per_capita_income_next30 ~ HealthSewerSanitation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_part)
tab7_mod2_se <- coeftest(tab7_mod2, function(x) vcovHC(x, type = 'sss'))
# regress model 3
tab7_mod3 <- plm(CPI_per_capita_income_next30 ~ Education_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_full)
tab7_mod3_se <- coeftest(tab7_mod3, function(x) vcovHC(x, type = 'sss'))
# regress model 4
tab7_mod4 <- plm(CPI_per_capita_income_next30 ~ Education_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_part)
tab7_mod4_se <- coeftest(tab7_mod4, function(x) vcovHC(x, type = 'sss'))
# regress model 5
tab7_mod5 <- plm(CPI_per_capita_income_next30 ~ Transportation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_full)
tab7_mod5_se <- coeftest(tab7_mod5, function(x) vcovHC(x, type = 'sss'))
# regress model 6
tab7_mod6 <- plm(CPI_per_capita_income_next30 ~ Transportation_pc + 
                   CPI_per_capita_income + foreignborn_pct + black_pct + 
                   othernonwhite_pct + urban_pct + south,
                 index = "year", data = df_tab7_part)
tab7_mod6_se <- coeftest(tab7_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 7
stargazer(tab7_mod1_se, tab7_mod2_se, tab7_mod3_se, 
          tab7_mod4_se, tab7_mod5_se, tab7_mod6_se,
          header = F, type = "latex", font.size = "tiny", style = "apsr", digits = 2,
          title = "Education Spending Levels Predict Income in Pre-New Deal Period",
          column.labels = c("Full sample", "1880-1940", 
                            "Full sample", "1880-1940",
                            "Full sample", "1880-1940"),
          covariate.labels = c("Health, sewer, sanitation spending per capita",
                               "Education spending per capita", 
                               "Transportation spending per capita", 
                               "Income per capita",
                               "Foreign-born pct", "Black pct", 
                               "Other nonwhite pct", "Urban population pct"),
          omit = c("Constant", "south", "year"),
          add.lines = list(c("State fixed effects", "No", "No",
                             "No", "No", "No", "No"),
                           c("Year fixed effects", "Yes", "Yes",
                             "Yes", "Yes", "Yes", "Yes"),
                           c("Observations", "336", "192", "408", 
                             "264", "384", "240"),
                           c("R-Squared", "0.13", "0.23", "0.12", 
                             "0.25", "0.14", "0.22"),
                           c("Adjusted R-Squared", "0.09", "0.18", "0.09", 
                             "0.21", "0.11", "0.18")))
```

\newpage

# Extension 4 (Unused): Removing the Year Fixed Effects from Table 1

```{r}
# subset data
df_tab4 <- df %>%
  filter(year > 1870 & year < 1990)
# regress model 1
tab4_mod1 <- plm(Education_pc ~ leg_party_competition, 
                 index = "state", data = df_tab4)
tab4_mod1_se <- coeftest(tab4_mod1, function(x) vcovHC(x, type = 'sss'))
# regress model 2
tab4_mod2 <- plm(Education_pc ~ leg_party_competition + Statewide_Competition + 
                                house_dem + senate_dem + gov_dem + 
                                CPI_per_capita_income + foreignborn_pct + 
                                black_pct + othernonwhite_pct + urban_pct, 
                 index = "state", data = df_tab4)
tab4_mod2_se <- coeftest(tab4_mod2, function(x) vcovHC(x, type = 'sss'))
# regress model 3
tab4_mod3 <- plm(HealthSewerSanitation_pc ~ leg_party_competition,
                 index = "state", data = df_tab4)
tab4_mod3_se <- coeftest(tab4_mod3, function(x) vcovHC(x, type = 'sss'))
# regress model 4
tab4_mod4 <- plm(HealthSewerSanitation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct,
                 index = "state", data = df_tab4)
tab4_mod4_se <- coeftest(tab4_mod4, function(x) vcovHC(x, type = 'sss'))
# regress model 5
tab4_mod5 <- plm(Transportation_pc ~ leg_party_competition,
                 index = "state", data = df_tab4)
tab4_mod5_se <- coeftest(tab4_mod5, function(x) vcovHC(x, type = 'sss'))
    
# regress model 6             
tab4_mod6 <- plm(Transportation_pc ~ leg_party_competition + 
                                Statewide_Competition  + house_dem + senate_dem +
                                gov_dem + CPI_per_capita_income + foreignborn_pct +
                                black_pct + othernonwhite_pct + urban_pct,
                 index = "state", data = df_tab4)
tab4_mod6_se <- coeftest(tab4_mod6, function(x) vcovHC(x, type = 'sss'))
```

```{r, results = "asis"}
# print Table 4
stargazer(tab4_mod1_se, tab4_mod2_se, tab4_mod3_se, 
          tab4_mod4_se, tab4_mod5_se, tab4_mod6_se,
          header = F, type = "latex", digits = 2, style = "apsr",
          title = "Party Competition Predicts Higher Human Capital and Infrastructure Spending, 1880-1980",
          column.labels = c("Education spending", "Health spending",
                            "Transportation spending"),
          column.separate = c(2, 2, 2),
          covariate.labels = c("Legislative party competition",
                               "Electoral competition", "Democratic house",
                               "Democratic senate", "Democratic governor",
                               "Income per capita", "Foreign-born percentage",
                               "Black percentage", "Other nonwhite percentage", 
                               "Urban population percentage"),
          omit = c("Constant"),
          add.lines = list(c("State fixed effects", "Yes", "Yes",
                             "Yes", "Yes", "Yes", "Yes"),
                           c("Year fixed effects", "No", "No",
                             "No", "No", "No", "No"),
                           c("Observations", "398", "380", "326", "310", "374", "357"),
                           c("R-Squared", "0.15", "0.94", "0.18", "0.87", "0.13", "0.80"),
                           c("Adj. R-Squared", "0.03", "0.93", "0.04", "0.84", "0.00", "0.77")))
```

\newpage

# Extension 5 (Unused): Visualizing Party Competition over Time

```{r}
df_extfig1 <- df %>%
  select(state, year, leg_party_competition) %>%
  filter(year >= 1880 & year <= 2010)
df_extfig1 %>%
  ggplot(aes(x = year, y = leg_party_competition, group = state)) +
  geom_line() +
  theme_bw()
```

\newpage

# Coefficient Plot: Table 1

```{r coef plot}
coef_df1 <- tribble(
~Estimate, ~SE, ~DV, ~IV, ~Confounders, ~Specification,
tab1_mod1_se[1,][1], tab1_mod1_se[1,][2], "Education Spending", "Leg. Party Comp.", "No", "Fixed Effects",
lag1_mod1_se[2,][1], lag1_mod1_se[2,][2], "Education Spending", "Leg. Party Comp.", "No", "Lag + FE",
lag3_mod1_se[2,][1], lag3_mod1_se[2,][2], "Education Spending", "Leg. Party Comp.", "No", "Lag, No FE",
tab5_mod1_se[1,][1], tab5_mod1_se[1,][2], "Education Spending", "Leg. Party Comp.", "No", "No Lag or FE",
tab1_mod2_se[1,][1], tab1_mod2_se[1,][2], "Education Spending", "Leg. Party Comp.", "Yes", "Fixed Effects",
lag1_mod2_se[2,][1], lag1_mod2_se[2,][2], "Education Spending", "Leg. Party Comp.", "Yes", "Lag + FE",
lag3_mod2_se[2,][1], lag3_mod2_se[2,][2], "Education Spending", "Leg. Party Comp.", "Yes", "Lag, No FE",
tab5_mod2_se[1,][1], tab5_mod2_se[1,][2], "Education Spending", "Leg. Party Comp.", "Yes", "No Lag or FE",
tab1_mod3_se[1,][1], tab1_mod3_se[1,][2], "Health Spending", "Leg. Party Comp.", "No", "Fixed Effects",
lag1_mod3_se[2,][1], lag1_mod3_se[2,][2], "Health Spending", "Leg. Party Comp.", "No", "Lag + FE",
lag3_mod3_se[2,][1], lag3_mod3_se[2,][2], "Health Spending", "Leg. Party Comp.", "No", "Lag, No FE",
tab5_mod3_se[1,][1], tab5_mod3_se[1,][2], "Health Spending", "Leg. Party Comp.", "No", "No Lag or FE",
tab1_mod4_se[1,][1], tab1_mod4_se[1,][2], "Health Spending", "Leg. Party Comp.", "Yes", "Fixed Effects",
lag1_mod4_se[2,][1], lag1_mod4_se[2,][2], "Health Spending", "Leg. Party Comp.", "Yes", "Lag + FE",
lag3_mod4_se[2,][1], lag3_mod4_se[2,][2], "Health Spending", "Leg. Party Comp.", "Yes", "Lag, No FE",
tab5_mod4_se[1,][1], tab5_mod4_se[1,][2], "Health Spending", "Leg. Party Comp.", "Yes", "No Lag or FE",
tab1_mod5_se[1,][1], tab1_mod5_se[1,][2], "Transportation Spending", "Leg. Party Comp.", "No", "Fixed Effects",
lag1_mod5_se[2,][1], lag1_mod5_se[2,][2], "Transportation Spending", "Leg. Party Comp.", "No", "Lag + FE",
lag3_mod5_se[2,][1], lag3_mod5_se[2,][2], "Transportation Spending", "Leg. Party Comp.", "No", "Lag, No FE",
tab5_mod5_se[1,][1], tab5_mod5_se[1,][2], "Transportation Spending", "Leg. Party Comp.", "No", "No Lag or FE",
tab1_mod6_se[1,][1], tab1_mod6_se[1,][2], "Transportation Spending", "Leg. Party Comp.", "Yes", "Fixed Effects",
lag1_mod6_se[2,][1], lag1_mod6_se[2,][2], "Transportation Spending", "Leg. Party Comp.", "Yes", "Lag + FE",
lag3_mod6_se[2,][1], lag3_mod6_se[2,][2], "Transportation Spending", "Leg. Party Comp.", "Yes", "Lag, No FE",
tab5_mod6_se[1,][1], tab5_mod6_se[1,][2], "Transportation Spending", "Leg. Party Comp.", "Yes", "No Lag or FE"
) %>%
  mutate(min = Estimate - 1.96*SE,
         max = Estimate + 1.96*SE)
coef_df1$y_pos <- c(10.2, 10.4, 10.6, 10.8,
                    8.2, 8.4, 8.6, 8.8,
                    6.2, 6.4, 6.6, 6.8,
                    4.2, 4.4, 4.6, 4.8,
                    2.2, 2.4, 2.6, 2.8,
                    0.2, 0.4, 0.6, 0.8)
coef_df1 %>%
  ggplot() +
  geom_point(aes(x = Estimate, y = y_pos, fill = Specification, shape = Specification), size = 3) +
  geom_errorbarh(aes(xmin = min, xmax = max, y = y_pos, col = Specification, height = 0)) +
  geom_hline(yintercept = c(3.5, 7.5)) +
  geom_vline(xintercept = 0, col = 'red', lty = 'dashed') +
  theme_minimal() +
  labs(x = 'Coefficient Estimate', y = '') +
  geom_text(x = -0.9, y = 9.5, label = "DV: Education Spending") +
  geom_text(x = -1., y = 5.5, label = "DV: Health Spending") +
  geom_text(x = -0.7, y = 1.5, label = "DV: Transportation Spending") +
  geom_text(x = 3, y = 10.5, label = "No Covariates (Model 1)", size = 3) +
  geom_text(x = 3, y = 8.5, label = "With Covariates (Model 2)", size = 3) +
  geom_text(x = 3, y = 6.5, label = "No Covariates (Model 3)", size = 3) +
  geom_text(x = 3, y = 4.5, label = "With Covariates (Model 4)", size = 3) +
  geom_text(x = 3, y = 2.5, label = "No Covariates (Model 5)", size = 3) +
  geom_text(x = 3, y = 0.5, label = "With Covariates (Model 6)", size = 3) +
  theme(axis.text.y = element_blank()) +
  scale_fill_manual(values = c('#00BFC4', '#C77CFF', '#F8766D', '#7CAE00')) + 
  scale_color_manual(values = c('#00BFC4', '#C77CFF', '#F8766D', '#7CAE00')) + 
  scale_shape_manual(values = c(21, 22, 23, 24)) +
  ggtitle("Party Competition Does NOT Predict Higher \nHuman Capital and Infrastructure Spending, 1880-1980",
          subtitle = "Coefficient Plot for Table 1 \nIV: Legislative Party Competition") +
  theme(plot.title = element_text(hjust = 0.5))
```

\newpage

# Coefficient Plot: Table 2

```{r}
coef_df2 <- tribble(
~Estimate, ~SE, ~DV, ~IV, ~Specification,
tab2_mod1_se[1,][1], tab2_mod1_se[1,][2], "Infant Mortality", "Health, etc. Spending", "Fixed Effects",
lag2_mod1_se[2,][1], lag2_mod1_se[2,][2], "Infant Mortality", "Health, etc. Spending", "Lag + FE",
lag4_mod1_se[2,][1], lag4_mod1_se[2,][2], "Infant Mortality", "Health, etc. Spending", "Lag, No FE",
tab6_mod1_se[1,][1], tab6_mod1_se[1,][2], "Infant Mortality", "Health, etc. Spending", "No Lag or FE",
tab2_mod2_se[1,][1], tab2_mod2_se[1,][2], "Life Expectancy", "Health, etc. Spending", "Fixed Effects",
lag2_mod2_se[2,][1], lag2_mod2_se[2,][2], "Life Expectancy", "Health, etc. Spending", "Lag + FE",
lag4_mod2_se[2,][1], lag4_mod2_se[2,][2], "Life Expectancy", "Health, etc. Spending", "Lag, No FE",
tab6_mod2_se[1,][1], tab6_mod2_se[1,][2], "Life Expectancy", "Health, etc. Spending", "No Lag or FE",
tab2_mod3_se[1,][1], tab2_mod3_se[1,][2], "High School Completion", "Education Spending", "Fixed Effects",
lag2_mod3_se[2,][1], lag2_mod3_se[2,][2], "High School Completion", "Education Spending", "Lag + FE",
lag4_mod3_se[2,][1], lag4_mod3_se[2,][2], "High School Completion", "Education Spending", "Lag, No FE",
tab6_mod3_se[1,][1], tab6_mod3_se[1,][2], "High School Completion", "Education Spending", "No Lag or FE",
tab2_mod4_se[1,][1], tab2_mod4_se[1,][2], "Illiteracy Rate", "Education Spending", "Fixed Effects",
lag2_mod4_se[2,][1], lag2_mod4_se[2,][2], "Illiteracy Rate", "Education Spending", "Lag + FE",
lag4_mod4_se[2,][1], lag4_mod4_se[2,][2], "Illiteracy Rate", "Education Spending", "Lag, No FE",
tab6_mod4_se[1,][1], tab6_mod4_se[1,][2], "Illiteracy Rate", "Education Spending",  "No Lag or FE"
) %>%
  mutate(min = Estimate - 1.96*SE,
         max = Estimate + 1.96*SE)
coef_df2$y_pos <- c(6.2, 6.4, 6.6, 6.8,
                    4.2, 4.4, 4.6, 4.8,
                    2.2, 2.4, 2.6, 2.8,
                    0.2, 0.4, 0.6, 0.8)
coef_df2 %>%
  ggplot() +
  geom_point(aes(x = Estimate, y = y_pos, fill = Specification, shape = Specification), size = 3) +
  geom_errorbarh(aes(xmin = min, xmax = max, y = y_pos, col = Specification,
                     height = 0)) +
  geom_hline(yintercept = c(1.5, 3.5, 5.5, 7.5)) +
  theme_minimal() +
  labs(x = 'Coefficient Estimate', y = '') +
  theme(axis.text.y = element_blank()) +
  geom_text(x = -0.045, y = 7.2, label = "DV: Infant Mortality (Model 1)") +
  geom_text(x = -0.045, y = 5.2, label = "DV: Life Expectancy (Model 2)") +
  geom_text(x = -0.045, y = 3.2, label = "DV: HS Completion (Model 3)") +
  geom_text(x = -0.045, y = 1.2, label = "DV: Illiteracy Rate (Model 4)") +
  geom_vline(xintercept = 0, col = 'red', lty = 'dashed') +
  scale_fill_manual(values = c('#00BFC4', '#C77CFF', '#F8766D', '#7CAE00')) + 
  scale_color_manual(values = c('#00BFC4', '#C77CFF', '#F8766D', '#7CAE00')) + 
  scale_shape_manual(values = c(21, 22, 23, 24)) +
  ggtitle("Health and Education Spending Levels \nDo NOT Predict Development, 1880-2010", 
          subtitle = "Coefficient Plot for Table 2 \nIVs: Health Spending (Models 1/2), Educ. Spending (Models 3/4)") +
  theme(plot.title = element_text(hjust = 0.5))
```

\newpage

# Coefficient Plot: Table 3

```{r}
coef_df3 <- tribble(
~Estimate, ~SE, ~DV, ~IV, ~Model, ~Results,
tab3_mod1_se[1,][1], tab3_mod1_se[1,][2], "Income per capita", "Health spending", "1", "Original",
tab3_mod1_se[1,][1], tab3_mod1_se[1,][2], "Income per capita", "Health spending", "1", "Replication",
tab7_mod1_se[1,][1], tab7_mod1_se[1,][2], "Income per capita", "Health spending", "1", "No FE",
tab3_mod1_se[2,][1], tab3_mod1_se[2,][2], "Income per capita", "Health spending", "1", "Original",
tab3_mod1_se[2,][1]+1, tab3_mod1_se[2,][2], "Income per capita", "Health spending", "1", "Replication",
tab7_mod1_se[2,][1], tab7_mod1_se[2,][2], "Income per capita", "Health spending", "1", "No FE",
tab3_mod2_se[1,][1], tab3_mod2_se[1,][2], "Income per capita", "Health spending", "2", "Original",
tab3_mod2_se[1,][1], tab3_mod2_se[1,][2], "Income per capita", "Health spending", "2", "Replication",
tab7_mod2_se[1,][1], tab7_mod2_se[1,][2], "Income per capita", "Health spending", "2", "No FE",
tab3_mod2_se[2,][1], tab3_mod2_se[2,][2], "Income per capita", "Health spending", "2", "Original",
tab3_mod2_se[2,][1]+1, tab3_mod2_se[2,][2], "Income per capita", "Health spending", "2", "Replication",
tab7_mod2_se[2,][1], tab7_mod2_se[2,][2], "Income per capita", "Health spending", "2", "No FE",
tab3_mod3_se[1,][1], tab3_mod3_se[1,][2], "Income per capita", "Education spending", "3", "Original",
tab3_mod3_se[1,][1], tab3_mod3_se[1,][2], "Income per capita", "Education spending", "3", "Replication",
tab7_mod3_se[1,][1], tab7_mod3_se[1,][2], "Income per capita", "Education spending", "3", "No FE",
tab3_mod3_se[2,][1], tab3_mod3_se[2,][2], "Income per capita", "Education spending", "3", "Original",
tab3_mod3_se[2,][1]+1, tab3_mod3_se[2,][2], "Income per capita", "Education spending", "3", "Replication",
tab7_mod3_se[2,][1], tab7_mod3_se[2,][2], "Income per capita", "Education spending", "3", "No FE",
tab3_mod4_se[1,][1], tab3_mod4_se[1,][2], "Income per capita", "Education spending", "4", "Original",
tab3_mod4_se[1,][1], tab3_mod4_se[1,][2], "Income per capita", "Education spending", "4", "Replication",
tab7_mod4_se[1,][1], tab7_mod4_se[1,][2], "Income per capita", "Education spending", "4", "No FE",
tab3_mod4_se[2,][1], tab3_mod4_se[2,][2], "Income per capita", "Education spending", "4", "Original",
tab3_mod4_se[2,][1]+1, tab3_mod4_se[2,][2], "Income per capita", "Education spending", "4", "Replication",
tab7_mod4_se[2,][1], tab7_mod4_se[2,][2], "Income per capita", "Education spending", "4", "No FE",
tab3_mod5_se[1,][1], tab3_mod5_se[1,][2], "Income per capita", "Transportation spending", "5", "Original",
tab3_mod5_se[1,][1], tab3_mod5_se[1,][2], "Income per capita", "Transportation spending", "5", "Replication",
tab7_mod5_se[1,][1], tab7_mod5_se[1,][2], "Income per capita", "Transportation spending", "5", "No FE",
tab3_mod5_se[2,][1], tab3_mod5_se[2,][2], "Income per capita", "Transportation spending", "5", "Original",
tab3_mod5_se[2,][1]+1, tab3_mod5_se[2,][2], "Income per capita", "Transportation spending", "5", "Replication",
tab7_mod5_se[2,][1], tab7_mod5_se[2,][2], "Income per capita", "Transportation spending", "5", "No FE",
tab3_mod6_se[1,][1], tab3_mod6_se[1,][2], "Income per capita", "Transportation spending", "6", "Original",
tab3_mod6_se[1,][1], tab3_mod6_se[1,][2], "Income per capita", "Transportation spending", "6", "Replication",
tab7_mod6_se[1,][1], tab7_mod6_se[1,][2], "Income per capita", "Transportation spending", "6", "No FE",
tab3_mod6_se[2,][1], tab3_mod6_se[2,][2], "Income per capita", "Transportation spending", "6", "Original",
tab3_mod6_se[2,][1]+1, tab3_mod6_se[2,][2], "Income per capita", "Transportation spending", "6", "Replication",
tab7_mod6_se[2,][1], tab7_mod6_se[2,][2], "Income per capita", "Transportation spending", "6", "No FE",
) %>%
  mutate(min = Estimate - 1.96*SE,
         max = Estimate + 1.96*SE)
coef_df3$y_pos <- c(10.9, 11.1, 11.3, 11.9, 12.1, 12.3,
                    8.9, 9.1, 9.3, 9.9, 10.1, 10.3,
                    6.9, 7.1, 7.3, 7.9, 8.1, 8.3,
                    4.9, 5.1, 5.3, 5.9, 6.1, 6.3,
                    2.9, 3.1, 3.3, 3.9, 4.1, 4.3,
                    0.9, 1.1, 1.3, 1.9, 2.1, 2.3)
coef_df3 %>%
  ggplot() +
  geom_point(aes(x = Estimate, y = y_pos, fill = Results, shape = Results), size = 3) +
  geom_hline(yintercept = c(2.5, 4.5, 6.5, 8.5, 10.5)) +
  theme_minimal() +
  labs(x = 'Coefficient Estimate', y = '') +
  theme(axis.text.y = element_blank()) +
  geom_errorbarh(aes(xmin = min, xmax = max, y = y_pos, col = Results,
                     height = 0)) +
  geom_text(x = 25, y = 12, label = "Health Spending (Full Sample)", size = 2.5) +
  geom_text(x = 25, y = 11, label = "Income Per Capita (Full Sample)", size = 2.5) +
  geom_text(x = -10, y = 11.5, label = "Model 1") +
  geom_text(x = 25, y = 10, label = "Health Spending (1880-1940)", size = 2.5) +
  geom_text(x = 25, y = 9, label = "Income Per Capita (1880-1940)", size = 2.5) +
  geom_text(x = -10, y = 9.5, label = "Model 2") +
  geom_text(x = 25, y = 8, label = "Educ. Spending (Full Sample)", size = 2.5) +
  geom_text(x = 25, y = 7, label = "Income Per Capita (Full Sample)", size = 2.5) +
  geom_text(x = -10, y = 7.5, label = "Model 3") +
  geom_text(x = 25, y = 6, label = "Educ. Spending (1880-1940)", size = 2.5) +
  geom_text(x = 25, y = 5, label = "Income Per Capita (1880-1940)", size = 2.5) +
  geom_text(x = -10, y = 5.5, label = "Model 4") +
  geom_text(x = 25, y = 4, label = "Transp. Spending (Full Sample)", size = 2.5) +
  geom_text(x = 25, y = 3, label = "Income Per Capita (Full Sample)", size = 2.5) +
  geom_text(x = -10, y = 3.5, label = "Model 5") +
  geom_text(x = 25, y = 2, label = "Transp. Spending (1880-1940)", size = 2.5) +
  geom_text(x = 25, y = 1, label = "Income Per Capita (1880-1940)", size = 2.5) +
  geom_text(x = -10, y = 1.5, label = "Model 6") +
  geom_vline(xintercept = 0, col = 'red', lty = 'dashed') +
  scale_shape_manual(values = c(21, 22, 23)) +
  ggtitle("Coefficient Plot: Table 3", subtitle = "(DV: Income Per Capita, 30 Years Later)") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_continuous(limits = c(-11, 30))
```
